#include "mainwindow.h"

#include <QApplication>

#include "desktopwindow.h"

#include <widget-loader.h>
#include <widget-container.h>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    UkuiQuick::WidgetContainer::widgetLoader().addWidgetSearchPath(QStringLiteral(":/"));
    DesktopWindow testDesktop(1, qApp->primaryScreen());
    testDesktop.show();

    DesktopWindow testDesktop2(2, qApp->screenAt(QCursor::pos()));
    testDesktop2.show();

    MainWindow w;
    w.show();

    QObject::connect(&w, &MainWindow::requestAddWidget, &a, [&](int screen){
        switch (screen) {
        case 1:
            testDesktop.addWidget(w.currentString());
            break;
        case 2:
            testDesktop2.addWidget(w.currentString());
            break;
        default:
            break;
        }
    });

    QObject::connect(&w, &MainWindow::requestRemoveWidget, &a, [&](int screen){
        switch (screen) {
        case 1:
            testDesktop.removeWidget();
            break;
        case 2:
            testDesktop2.removeWidget();
            break;
        default:
            break;
        }
    });
    QObject::connect(&w, &MainWindow::requestClearAll, &a, [&](){
        testDesktop.clearAll();
        testDesktop2.clearAll();
    });
    return a.exec();
}
